import com.zueb.pojo.Admin;
import com.zueb.pojo.Classes;
import com.zueb.pojo.Faculty;
import com.zueb.pojo.UserInfo;
import com.zueb.service.AdminService;
import com.zueb.service.FacultyService;
import com.zueb.service.UserInfoService;
import com.zueb.service.UserService;
import com.zueb.service.impl.AdminServiceImpl;
import com.zueb.service.impl.FacultyServiceImpl;
import com.zueb.service.impl.UserInfoServiceImpl;
import com.zueb.service.impl.UserServiceImpl;
import com.zueb.util.MD5;
import org.junit.Test;

import java.util.List;

public class DruidDemo {

    @Test
    public void getAdmin(){
        AdminService adminService = new AdminServiceImpl();
        List<Admin> admins = adminService.getAllAdmin(0,0);

        System.out.println(admins);
    }

    @Test
    public void getMD5(){
        String pass = "123";
        pass = MD5.md5(pass);
        System.out.println(pass);
    }

    @Test
    public void getStudent(){
        UserService userService = new UserServiceImpl();
        String userRole = "学生";
        List<UserInfo> allUser = userService.getAllUser(userRole);

        System.out.println(allUser);

    }

    @Test
    public void getClasses(){
        FacultyService facultyService = new FacultyServiceImpl();
        int facultyId = 2;
        //获取学院列表
        List<Faculty> faculties = facultyService.getAllFaculty();
        //从数据库中得到班级列表
        List<Classes> classes = facultyService.getClassesByFaculty(facultyId);
        System.out.println(faculties);
        System.out.println(classes);
    }

    @Test
    public  void updateUserInfo(){
        UserInfoService userInfoService = new UserInfoServiceImpl();
        String userNumber = "201801024215";
        UserInfo getUserInfo = new UserInfo();
        getUserInfo.setUserNumber(userNumber);
        getUserInfo.setRegiste("已注册");  //更改注册信息为“已注册”

        UserInfo userInfo = userInfoService.getUserInfoByNumber(userNumber);
        userInfoService.updateUserInfoByNumber(getUserInfo);
        UserInfo userInfo2 = userInfoService.getUserInfoByNumber(userNumber);
        System.out.println(userInfo);
        System.out.println(userInfo2);

    }

}
